<template>
  <a-modal
    :title="title"
    :width="1600"
    :visible="visible"
    @cancel="handleCancel"
    :cancelText="$t('systemManagement.close')"
    wrapClassName="ant-modal-cust-warp"
    style="top:5%;height: 100%;overflow-y: hidden">
    <template slot="footer">
      <a-button id="printBtn" key="back" v-print="'#reportPrintCopy'">{{$t('reportQuery.print')}}</a-button>
    </template>
    <!-- table区域-begin -->
    
    <section ref="print" id="reportPrintCopy">
      <div style="padding:10px;text-align:center">
        <div>{{$route.name}} - {{getLocalStorage('pro__Login_Userinfo').loginName}}</div>
      <div>{{queryParam.beginTime || (queryParam.search && queryParam.search.beginTime) || ''}}~{{queryParam.endTime || (queryParam.search && queryParam.search.endTime) || ''}}</div>
      </div>
    <a-table
      bordered
      ref="table"
      size="middle"
      rowKey="id"
      :columns="columns"
      :dataSource="list"
      :pagination="ipagination"
      >
      <span slot="numberCustomRender" slot-scope="text, record">
        <a @click="myHandleDetail(record)">{{record.number}}</a>
      </span>
    </a-table>
    </section>
    <!-- table区域-end -->
    <!-- 表单区域 -->
  </a-modal>
</template>
<script>
  import JEllipsis from '@/components/jeecg/JEllipsis'
  import {findBillDetailByNumber, findFinancialDetailByNumber} from '@/api/api'
  export default {
    name: "AccountInOutList",
    components: {
      JEllipsis
    },
    props: {
      list: {
        type: Array,
        default: ()=>[]
      },
      columns: {
        type: Array,
        default: ()=>[]
      },
      queryParam: {
        type: Object,
        default: ()=>{}
      },
    },
    data () {
      return {
        title:this.$t('setailManagement.operation'),
        visible: false,
        disableMixinCreated: false,
        toFromType: '',
        // 查询条件
        ipagination:{
          pageSize: 11,
          pageSizeOptions: ['11', '21', '31', '101', '201']
        },
      printDirectiveData:{
        printType:1,//不走打印次数权限
      },//权限打印参数
        tabKey: "1",
        // 表头
        labelCol: {
          xs: { span: 1 },
          sm: { span: 2 },
        },
        wrapperCol: {
          xs: { span: 10 },
          sm: { span: 16 },
        },
        url: {
          list: "/account/findAccountInOutList"
        }
      }
    },
    created() {
      console.log('this.queryParam :>> ', this.queryParam);
      console.log('printDirectiveData :>> ', this.printDirectiveData);
    },
    methods: {
      print(){
        let el = document.getElementById('printBtn')
        el.click()
      },
      // 获取localStorage数据
      getLocalStorage (key) {
        var value = localStorage.getItem(key) // 取回 value 变量
        this.localStorageKeyJson = JSON.parse(value)
        return this.localStorageKeyJson.value
      },
      getQueryParams() {
        let param = Object.assign({}, this.queryParam, this.isorter);
        param.field = this.getQueryField();
        param.currentPage = this.ipagination.current;
        param.pageSize = this.ipagination.pageSize;
        return param;
      },
      show() {
        this.visible = true;
        this.$nextTick(()=>{
          setTimeout(()=>{
            this.visible = false
          },200);
          this.print()
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      },
      myHandleDetail(record) {
        let that = this
        this.toFromType = record.fromType
        if(record.fromType === 'bill') {
          findBillDetailByNumber({ number: record.number }).then((res) => {
            if (res && res.code === 200) {
              that.$refs.billDetail.show(res.data, record.type);
              that.$refs.billDetail.title=this.$t('reportQuery.details');
            }
          })
        } else if(record.fromType === 'financial') {
          findFinancialDetailByNumber({ billNo: record.number }).then((res) => {
            if (res && res.code === 200) {
              that.$refs.financialDetail.show(res.data, record.type);
              that.$refs.financialDetail.title=this.$t('reportQuery.details');
            }
          })
        }
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>